<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:th="http://www.thymeleaf.org" xmlns:cb="http://www.ossbar.com/">
<head th:include="layout/head" />
<div th:include="layout/foot"></div>
<script type="text/javascript" th:inline="javascript">
	cb.loadmodules([ "validate", "ajax", "lay" ]);
</script>
<script type="text/javascript" charset="utf-8"
		th:src="@{/plugins/ueditor/ueditor.config.js}"></script>
<script type="text/javascript" charset="utf-8"
	th:src="@{/plugins/ueditor/ueditor.all.js}"></script>
<script type="text/javascript"
	th:src="@{/plugins/ueditor/lang/zh-cn/zh-cn.js}"></script>
<body>
<form class="form-horizontal" id="tmailAccountForm" th:action="@{/mail/tmailaccount/saveorupdate}" th:object="${tmailAccount}">
	<input type="hidden" id="maId" name="maId" th:field="*{maId}" />
		<input type="hidden" name="tokenForm"
			th:value="${#session.getAttribute('tokenForm')}" />
		<table class="table table-bordered FormView cb-table-fun">
				<tr>
				<td class="cb-label">邮箱类型</td>
				<td class="cb-value">
				<cb:dict cbid="mailType" name="maProtocol" type="select" th:value="*{maProtocol}"/>
				</td>
				<td class="cb-label">是否主账户</td>
				<td class="cb-value">
				<input type="radio" class="radio-inline" name="maIsMain" value="Y" th:checked="*{maIsMain=='Y' || maIsMain==null}">是
				<input type="radio" class="radio-inline" name="maIsMain" value="N" th:checked="*{maIsMain=='N'}">否
				</td>
				</tr>
				<tr>
				<td class="cb-label">邮箱账号</td>
				<td class="cb-value"><input type="text"
					class="form-control cb-form-control validate[required,maxSize[100]]" data-msg=""
					id="maAccount" name="maAccount" th:field="*{maAccount}" placeholder="邮箱账号" onblur="acctBlur(this);"/></td>
				<td class="cb-label">邮箱密码</td>
				<td class="cb-value"><input type="password"
					class="form-control cb-form-control validate[required,maxSize[100]]" data-msg=""
					id="maPasswd" name="maPasswd" th:value="*{maPasswd}" placeholder="邮箱密码" /></td>
				</tr>
				<tr>
				<td class="cb-label">邮箱显示名称</td>
				<td class="cb-value"><input type="text"
					class="form-control cb-form-control validate[required,maxSize[50]]" data-msg=""
					id="maShowname" name="maShowname" th:field="*{maShowname}" placeholder="邮箱显示名称" /></td>
				<td class="cb-label">收取邮件频率(分钟)</td>
				<td class="cb-value"><input type="number"
					class="form-control cb-form-control validate[maxSize[10]]" data-msg=""
					id="maMinute" name="maMinute" th:field="*{maMinute}" placeholder="收取邮件频率" /></td>
				</tr>
				<tr>
				<td class="cb-label">收件服务器</td>
				<td class="cb-value"><input type="text"
					class="form-control cb-form-control validate[required,maxSize[50]]" data-msg=""
					id="maReceServer" name="maReceServer" th:field="*{maReceServer}" placeholder="收件服务器" /></td>
				<td class="cb-label">收件服务器是否SSL</td>
				<td class="cb-value">
				<input type="radio" class="radio-inline" name="maRsIsssl" value="Y" th:checked="*{maRsIsssl=='Y'}">是
				<input type="radio" class="radio-inline" name="maRsIsssl" value="N" th:checked="*{maRsIsssl=='N' || maRsIsssl==null}">否
				</td>
				</tr>
				<tr>
				<td class="cb-label">收件服务器端口</td>
				<td class="cb-value"><input type="text"
					class="form-control cb-form-control validate[required,maxSize[10]]" data-msg=""
					id="maRsPort" name="maRsPort" th:field="*{maRsPort}" placeholder="收件服务器端口" /></td>
				</tr>
				<tr>
				<td class="cb-label">发件服务器</td>
				<td class="cb-value"><input type="text"
					class="form-control cb-form-control validate[required,maxSize[50]]" data-msg=""
					id="maSendServer" name="maSendServer" th:field="*{maSendServer}" placeholder="发件服务器" /></td>
				<td class="cb-label">发件服务器是否SSL</td>
				<td class="cb-value">
				<input type="radio" class="radio-inline" name="maSsIsssl" value="Y" th:checked="*{maSsIsssl=='Y'}">是
				<input type="radio" class="radio-inline" name="maSsIsssl" value="N" th:checked="*{maSsIsssl=='N' || maSsIsssl==null}">否
				</td>
				</tr>
				<tr>
				<td class="cb-label">发件服务器端口</td>
				<td class="cb-value"><input type="text"
					class="form-control cb-form-control validate[required,maxSize[10]]" data-msg=""
					id="maSsPort" name="maSsPort" th:field="*{maSsPort}" placeholder="发件服务器端口" /></td>
				</tr>
				<tr>
				<td class="cb-label">邮件签名状态</td>
				<td class="cb-value">
				<input type="radio" class="radio-inline" name="maSignState" value="Y" th:checked="*{maSignState=='Y' || maSignState==null}">启用
				<input type="radio" class="radio-inline" name="maSignState" value="N" th:checked="*{maSignState=='N'}">禁用
				</td>
				</tr>
				<tr>
				<td class="cb-label">邮件签名模板</td>
				<td class="cb-value" colspan="3">
				<div id="maSign" name="maSign" style="width:100%;height:300px;"></div>
				</tr>
		</table>
	</form>
</body>
<script type="text/javascript" th:inline="javascript">
	$("#maAccount").focus();
	function acctBlur(e){
		var account = $(e).val();
		if(account.indexOf("@") >= 0){
			var server = account.split("@")[1];
			$("#maSendServer").val("smtp."+server);
			$("#maReceServer").val("pop3."+server);
		}
	}
	if($("#maRsPort").val() == ""){
		$("#maRsPort").val("110");
	}
	if($("#maSsPort").val() == ""){
		$("#maSsPort").val("25");
	}
	$('input:radio[name="maRsIsssl"]').change(function(){
		if($(this).val() == 'Y'){
			$("#maRsPort").val("995");
		}else{
			$("#maRsPort").val("110");
		}
	})
	$('input:radio[name="maSsIsssl"]').change(function(){
		if($(this).val() == 'Y'){
			$("#maSsPort").val("465");
		}else{
			$("#maSsPort").val("25");
		}
	})
	if(maSign){
		maSign.destroy();
	}
	var maSign = UE.getEditor("maSign");
	var maSignValue = [[${tmailAccount.maSign}]];
	if(maSignValue != null){
		maSign.ready(function() {//编辑器初始化完成再赋值  
			maSign.setContent(maSignValue);
		});
	}
	//保存
	top.cb.oper.save = function() {// save_click()
		cb.submit("#tmailAccountForm", "mail/tmailaccount/saveorupdate", function(data) {
			if(data.error){
				cb.alert(data.error);
				return false;
			}else{
				cb.alert("保存成功", function() {
					cb.winclose()
				});
			}
		}, {
			contentType : "application/x-www-form-urlencoded"
		})
	}
	//保存并继续
	top.cb.oper.saveAndAdd = function(){
		cb.submit("#tmailAccountForm","mail/tmailaccount/saveorupdate",function(){
			cb.alert("保存成功",function(){location.reload(true); });// 提交后重置表单
			
		})
	}
</script>
</html>